package com.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class OwnerLoginController {

    @RequestMapping("/toLogins")
    public String toLogin(){
        return "logins";
    }

    @RequestMapping("/logins")
    public String login(String userCode, String password, Model model){
     /*  String userCode="zhangsan";
       String password="123456";*/
        //1.设置令牌，用户名和密码
     /*   UsernamePasswordToken token = new UsernamePasswordToken(userCode, password);
        //2.获取主体对象
        Subject subject = SecurityUtils.getSubject();
        try {
            subject.login(token);
            return "redirect:/ownerindex"; //redirect:重定向，登录、增删改
        }catch (UnknownAccountException | IncorrectCredentialsException e){
            model.addAttribute("loginErr","用户名或密码错误");
            return "logins";
        }*/
        return "";
    }

    @RequestMapping("/logouts")
    public String logout(){
        return "redirect:/toLogins";
    }
}
